package pl.vm.domain;

import pl.vm.domain.exceptions.InvalidStateException;
import pl.vm.domain.interfaces.Classification;
import pl.vm.domain.interfaces.RoundState;

public class RoundOpen implements RoundState {

	private RoundImpl round;

	public RoundOpen(RoundImpl round) {
		this.round = round;
	}

	@Override
	public void setPlayerStatistics(Player player, Statistics statistics)
			throws InvalidStateException {
		throw new InvalidStateException();
	}

	@Override
	public void changePlayerStatistics(Player player, Statistics statistics)
			throws InvalidStateException {
		throw new InvalidStateException();
	}
	
	@Override
	public boolean addTeam(VirtualTeam team) throws InvalidStateException {
		return round.getTeams().add(team);
	}

	@Override
	public void close() throws InvalidStateException {
		throw new InvalidStateException();
	}

	@Override
	public void freeze() throws InvalidStateException {
		round.setState(round.FROZEN);
	}

	@Override
	public Classification getClassification() {		
		return round.classification;
	}

	@Override
	public boolean changeTeam(VirtualTeam oldTeam, VirtualTeam newTeam) throws InvalidStateException {
		round.getTeams().remove(oldTeam);		
		return round.getTeams().add(newTeam);
	}
}
